package com.unify.python.config;

import com.unify.python.util.PropertiesUtil;
import java.util.Objects;

/**
 * @Author: wchen
 * @Description:
 * @Date: Created in 2018-12-19 09:59
 * Copyright 本内容仅限于杭州阿拉丁信息科技股份有限公司内部传阅，禁止外泄以及用于其他的商业目的
 */
public class PythonConfig {

    public static int connectionTimeout = 10000;// 设置连接建立的超时时间为10s
    public static int socketTimeout = 10000;
    public static int maxConn = 5; // 最大连接数
    public static int maxPreRoute = 50;   //最大路由链接数
    public static int defaultRoute = 50;   //默认路由链接数
    public static int httpIdlTimeout = 10;    //http链接最大空闲时间
    public static int httpMonitorInterval = 300;   //处理空闲链接的周期
    public static int httpInitDelay = 10; //处理空闲链接初始延迟时间
    public static int sysHttpConnRetry = 3; //httpClient本身的重试次数
    public static int httpConnRetry = 3; //自定义请求的重试次数
    static  {
        String connectionTimeoutConfig = PropertiesUtil.getProperty("connectionTimeout");
        if(Objects.nonNull(connectionTimeoutConfig)){
            connectionTimeout = Integer.parseInt(connectionTimeoutConfig);
        }

        String socketTimeoutConfig = PropertiesUtil.getProperty("socketTimeout");
        if(Objects.nonNull(socketTimeoutConfig)){
            socketTimeout = Integer.parseInt(socketTimeoutConfig);
        }

        String maxConnConfig = PropertiesUtil.getProperty("maxConn");
        if(Objects.nonNull(maxConnConfig)){
            maxConn = Integer.parseInt(maxConnConfig);
        }

        String maxPreRouteConfig = PropertiesUtil.getProperty("maxPreRoute");
        if(Objects.nonNull(maxPreRouteConfig)){
            maxPreRoute = Integer.parseInt(maxPreRouteConfig);
        }

        String defaultRouteConfig = PropertiesUtil.getProperty("defaultRoute");
        if(Objects.nonNull(defaultRouteConfig)){
            defaultRoute = Integer.parseInt(defaultRouteConfig);
        }
        String httpIdlTimeoutConfig = PropertiesUtil.getProperty("httpIdlTimeout");
        if(Objects.nonNull(httpIdlTimeoutConfig)){
            httpIdlTimeout = Integer.parseInt(httpIdlTimeoutConfig);
        }

        String httpMonitorIntervalConfig = PropertiesUtil.getProperty("httpMonitorInterval");
        if(Objects.nonNull(httpMonitorIntervalConfig)){
            httpMonitorInterval = Integer.parseInt(httpMonitorIntervalConfig);
        }

        String httpInitDelayConfig = PropertiesUtil.getProperty("httpInitDelay");
        if(Objects.nonNull(httpInitDelayConfig)){
            httpInitDelay = Integer.parseInt(httpInitDelayConfig);
        }
        String sysHttpConnRetryConfig = PropertiesUtil.getProperty("sysHttpConnRetry");
        if(Objects.nonNull(sysHttpConnRetryConfig)){
            sysHttpConnRetry = Integer.parseInt(sysHttpConnRetryConfig);
        }
        String httpConnRetryConfig = PropertiesUtil.getProperty("httpConnRetry");
        if(Objects.nonNull(httpConnRetryConfig)){
            httpConnRetry = Integer.parseInt(httpConnRetryConfig);
        }

    }

}
